import { createApp } from 'vue'
import { createPinia } from 'pinia'
import App from './App.vue'
import router from './router'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import zhCn from 'element-plus/es/locale/lang/zh-cn' // 引入中文语言包
import axios from 'axios' // 确保导入axios

const pinia = createPinia()
const app = createApp(App)

// 配置axios基础URL
axios.defaults.baseURL = 'http://localhost:8080' // 确保与后端地址一致

// 注册所有Element Plus图标
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}

app.use(pinia)
app.use(router)
// 只调用一次 app.use(ElementPlus)，并传入 locale 配置
app.use(ElementPlus, { 
  locale: zhCn 
})

app.mount('#app')